import * as Vue from "vue";
import Dialog from "./common/Dialog";
import AjaxEx from "./common/AjaxEx";
import CSDialog from "./common/CSDialog";
import {Helpers} from "./common/Helpers";
import * as _ from 'lodash';

let apu = AjaxEx.getJsonData("/form/get")
//json对象必须有对应的值
Helpers.assert(apu && apu.versionid && apu.apuCfg)
console.log("load:" + JSON.stringify(apu))

let app= new Vue({
    el:'#app',
    data:{
        //设置对话框的绑定更方便
        dlg:{
            db:'orcl',
            schema:'test',
            id: 0
        },
        apuCfg: apu.apuCfg
    },
    beforeCreate: ()=>{
        console.log("vue init")
    },
    methods:{
        showdlg : ()=>{
            _.forOwn(app.$data['dlg'], function(value, key){
                console.log(`${key}: ${value}`);
            });
            console.log("###")
            //alert(JSON.stringify(app.$data["apuCfg"]))

            let dlg = new Dialog("#dlg", "#fdlg", "#bdlg")
            dlg.initShow((d) => {
                console.log(d)
                console.log(app.$data['dlg']['db'])
                console.log(app.$data['dlg']['id'])

                //apu.apuCfg = null
                AjaxEx.postJson(`/form/save?id=1`, JSON.stringify(apu), (d)=>{
                    console.log(d)
                })
            })
        },
        checkVo :()=>{
            AjaxEx.postJson(`/form/conv`, '{"fullName":"hello", "age":10}', (d)=>{
                console.log(d)
            })
        }
    }
})